<template>
  <view class="mine-container" :style="{height: `${windowHeight}px`}">
	  <uniNavBarMine :fixed="true" status-bar :border="false"> <!-- background-color="#92B4FE" -->
	  <!-- 			<block slot="left">
	  				<view style="border: 1px solid yellow;display: flex;flex-direction: row;align-items: center;justify-content: flex-end;margin-left: 4px;">
	  					<view style="width: 100rpx;display: flex;flex-direction: row;justify-content: flex-start;align-items: center;">
	  						<image src="../static/logo.png" style="width: 70rpx;height: 70rpx;"></image>
	  					</view>
	  				</view>
	  			</block>
	  			 -->
	  		 <view style="width: 100%;display: flex;flex-direction: row;justify-content: center;align-items: center;">
<!-- 				<view>
					标题
				</view> -->
			 </view>
	  	</uniNavBarMine>
	  
	  <view style="position: relative;z-index: 9999;border: 0px solid red;">
		<view style="padding: 15px;display: flex;justify-content: space-between;align-items: center;flex-direction: row;">
			
 			<view class="flex align-center" style="border: 0px solid black;">
<!-- 			  <view v-if="!avatar" style="border-radius: 50px;border: 1px solid #c2b292;background: none;width: 128upx;height: 128upx;">
			  </view> -->
			  <view v-if="name === ''">
				  <view  @click="handleAvatarToLoginTip" style="border-radius: 50px;border: 1px solid #c2b292;background: none;width: 128upx;height: 128upx;"></view> 
			  </view>
			  <view v-if="name !== ''" style="display: flex;flex-direction: row;">
				  <image :src="avatar" style="width: 128upx;height: 128upx;border-radius: 50px;" mode="scaleToFill">
					<button type="primary" open-type="chooseAvatar" @chooseavatar="getUserAvatar" plain="true" style="border-radius: 50px;border: 1px solid #c2b292;background: none;width: 128upx;height: 128upx;position: absolute;z-index: 9999;"></button>
				  </image>
			  </view>
			  
			  <view v-if="!name" style="color: #161819;font-weight: 500;" >
				  <view style="border: none;color: #161819;">
					   <button @click="openPopup" class="but-img">点击登录</button>
				</view>
			  </view>
			  <view v-if="name" style="margin-left: 15px;">
			    <view style="display: flex;flex-direction: column;">
				  <view style="color: #161819;font-size: 15px;padding: 5px;">
					  {{ name }}
				  </view>
				  <view style="display: flex;flex: 1;align-items: center;justify-content: center;background: linear-gradient(to right,#c2b292,#dacdbe);border-radius: 15px;padding: 5px;color: rgba(0,0,0,.8);">
					  {{userinfo.mallMember.memberName}}
				  </view>
			    </view>
			  </view>
			</view>
			
			<view style="display: flex;flex-direction: column;align-items: center;padding: 0px 0px 0px 10px;">
				<text v-if="name" style="font-size: 15px;font-weight: 600;color: #161819;">
					 {{userinfo.integralCount}}
				</text>
				<text v-if="!name" style="font-size: 15px;font-weight: 600;color: #161819;">
					 0
				</text>
				<view style="display: flex;flex-direction: row;align-items: center;">
					<image src="../../static/images/jifen.png" style="width: 25px;height: 25px;"></image>
					<text style="color: #161819;font-size: 14px;padding-left: 2px;font-weight: 600;">
						可用积分
					</text>
				</view>
			</view>
<!-- 			<view @click="handleToInfo" style="display: flex;align-items: center;padding: 0px 10px 0px 10px;" >
			  <image src="../../static/images/editUserInfo.png" style="width: 25px;height: 25px;"></image>
			</view> -->
		</view>
	  </view>
	  
<!-- 	  <view style="border: 1px solid black;height: 50px;">
	  </view> -->
	  
	  <view>
		<view style="display: flex;flex-direction: column;position: relative;z-index: 9999;margin: 10px;border-radius: 30px;background: linear-gradient(180deg,#dacdbe,#FAF2D8);padding: 10px;">
		  <view style="display: flex;flex-direction: row;justify-content: space-between;padding: 10px;align-items: center;">
			  <view style="height: 100%;color: #161819;font-size: 20px;display: flex;align-items: center;">
				  我的订单
			  </view>
			  <view @click="showAllOrder" style="height: 100%;display: flex;align-items: center;color: #8B8B8B;font-size: 15px;">
				<text>查看全部</text>
				<view class="iconfont icon-right"></view>
			  </view>
		  </view>
		  <view class="mine-actions grid col-4 text-center" style="height: 100%;display: flex;align-items: center;">
				<view class="action-item" @click="showAllOrderOne">
				   <image src="../../static/images/dfk.png" style="width: 28px;height: 28px;"></image>
				  <text class="text">待付款</text>
				</view>
				<view class="action-item" @click="showAllOrderTwo">
				  <image src="../../static/images/dfh.png" style="width: 28px;height: 28px;"></image>
				  <text class="text">待发货</text>
				</view>
				<view class="action-item" @click="showAllOrderThree">
					<view v-if="orderThreeVal > 0">
						<uni-badge  :text="orderThreeVal" absolute="rightTop" size="small">
							<image src="../../static/images/daishouhuo.png" style="width: 28px;height: 28px;"></image>
							<text class="text">待收货</text>
						</uni-badge>
					</view>
					<view v-if="orderThreeVal == 0">
						<image src="../../static/images/daishouhuo.png" style="width: 28px;height: 28px;"></image>
						<text class="text">待收货</text>
					</view>
				</view>
				<view class="action-item" @click="showAllOrderFour">
				  <image src="../../static/images/dpj.png" style="width: 28px;height: 28px;"></image>
				  <text class="text">已完成</text>
				</view>
		  </view>
		</view>
	  </view>

	<!-- border: 1px solid #dacdbe; 分割线-->
	<view style="margin: 15px 0;padding: 0 10px;">
		<view style="background-color: #dacdbe;height: 1px;">
		</view>
	</view>
	
	<!-- padding: 0 15px; -->
	<view class="content-section" style="position: relative;">
		<scroll-view scroll-top="0" scroll-y="true" :style="{height: `${windowHeight-420}px`}">
			<view style="padding: 10px;border-radius: 8px;background-color: white;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1)">
				<uni-grid :column="3" :show-border="false">
					<uni-grid-item :index="0">
						<view class="grid-item-box"  @click="handleAddRess">
							<image style="width: 35px;height: 35px;" src="../../static/images/address.png" mode="aspectFill" />
							<view style="color: #515151;font-size: 14px;padding-top: 10px;">
								收货地址
							</view>
						</view>
					</uni-grid-item>
<!-- 					<uni-grid-item :index="1">
						<view class="grid-item-box" @click="handleCoupon">
							<image style="width: 35px;height: 35px;" src="../../static/images/youhuiquan.png" mode="aspectFill" />
							<view style="color: #515151;font-size: 14px;padding-top: 10px;">
								优惠券-积分商城
							</view>
						</view>
					</uni-grid-item> -->
					<uni-grid-item :index="1">
						<view class="grid-item-box" @click="handleProblemDescribe">
							<image style="width: 35px;height: 35px;" src="../../static/images/problemDescribe.png" mode="aspectFill" />
							<view style="color: #515151;font-size: 14px;padding-top: 10px;">
								问题反馈
							</view>
						</view>
					</uni-grid-item>
					<uni-grid-item :index="2">
						<view class="grid-item-box" @click="handleCallService">
							<image style="width: 35px;height: 35px;" src="../../static/images/kefu.png" mode="aspectFill" />
							<view style="color: #515151;font-size: 14px;padding-top: 10px;">
								联系客服
							</view>
						</view>
					</uni-grid-item>
					<uni-grid-item :index="3">
						<view class="grid-item-box" @click="handEditPhoto">
							<image style="width: 35px;height: 35px;" src="../../static/images/photo22.png" mode="aspectFill" />
							<view style="color: #515151;font-size: 14px;padding-top: 10px;">
								修改头像
							</view>
						</view>
					</uni-grid-item>
<!-- 					<uni-grid-item :index="4">
						<view class="grid-item-box">
							<image style="width: 35px;height: 35px;" src="../../static/logo.png" mode="aspectFill" />
						</view>
					</uni-grid-item> -->
					<uni-grid-item :index="4">
						<view class="grid-item-box"  @click="handleLogout">
							<image style="width: 35px;height: 35px;" src="../../static/images/exitLogin.png" mode="aspectFill" />
							<view style="color: #515151;font-size: 14px;padding-top: 10px;">
								退出登录
							</view>
						</view>
					</uni-grid-item>
				</uni-grid>				
			</view>
			
<!-- 			<view style="padding: 30px 0 40px 0;border: 2px solid black;">
				<carousel :img-list="imgList" url-key="url" @selected="selectedBanner"/>
			</view> -->
			
			<view style="padding: 20px 0 20px 0;display: flex;flex-direction: row;justify-content: center;align-items: center;">
				<view @click="userXieYi" style="color: #8B8B8B;font-size: 14px;margin-right: 10px;">用户协议</view>
				<view style="height: 100%;color: #8B8B8B;">|</view>
				<view @click="userYinsi"  style="color: #8B8B8B;font-size: 14px;margin-left: 10px;">隐私政策</view>
			</view>
			<view class="popup" v-show="show">
			   <view class="mask"></view>
			   <view class="login-form" style="    border: 2px solid #f7d87c;border-radius: 10px;">
			     <view @click="codeLogin" style="font-size: 17px;
					text-align: center;
					height: 60rpx;padding: 10rpx;color: cornflowerblue;">
												<text>账号登录</text>
			     </view>
				 <button type="primary" open-type="getPhoneNumber" @getphonenumber="handleToLogin" plain="true" style="border: none;color: #161819;height: 77rpx;color: cornflowerblue; font-size: 17px;">微信授权</button>
			     <button @click="cancelPopup" style="font-size: medium;">取消</button>
			   </view>
			 </view>
			
		</scroll-view>
    </view>
	
<!-- 	<view style="border: 2px solid black;" :style="{height: `${windowHeight}px`}">
	</view> -->
<!-- 	<view style="padding-top: 10px;">
	</view> -->
	<!-- 问题反馈 -->
	<uni-popup ref="problemDescribePop" type="center" :animation="false" background-color="#fff" border-radius="10px 10px 0 0" :mask-click="false">
		<view style="background: linear-gradient(to right,#c2b292,#dacdbe);border-radius: 10px;display: flex;flex-direction: column;padding: 10px;" :style="{width: `${windowWidth-50}px`}">
			<view style="display: flex;flex-direction: row;align-items: center;justify-content: flex-end;">
				<uni-icons @click="closeProblemDescribePop" type="close" size="24" color="#675742"></uni-icons>
			</view>
			<view style="display: flex;flex-direction: column;margin: 10px 0 10px 0;flex: 1;">
				<uni-easyinput style="border-radius: 10px;" autoHeight trim="all" :inputBorder="false" type="textarea" v-model="problemDescribeVal" placeholder="请详细描述您要反馈的问题"></uni-easyinput>
			</view>
			<view style="display: flex;flex-direction: row;align-items: center;margin: 10px 0 10px 0;">
				<view @click="handAddProblem" style="border-radius: 25px;border: 1px solid rgba(0,0,0,.2);background-color: #F8F8F8;font-size: 15px;color: #666;flex: 1;display: flex;flex-direction: row;justify-content: center;align-items: center;padding: 5px 0 5px 0;">
					提交
				</view>
			</view>
			
		</view>
	</uni-popup>
	
	<!-- 登录弹框 -->
	<uni-popup ref="loginPop" type="center" :animation="false" background-color="#fff" border-radius="10px 10px 0 0" :mask-click="false">
		<view style="background-color: #F8F8F8;;border-radius: 10px;display: flex;flex-direction: column;padding: 10px;" :style="{width: `${windowWidth-50}px`}">
			<view style="display: flex;flex-direction: column;margin: 0px 0 10px 0;flex: 1;">
				<view style="display: flex;flex-direction: row;justify-content: center;">
					<image src="../../static/images/xiaolian.png" style="width: 50px;height: 50px;"></image>
				</view>
				<view style="display: flex;flex-direction: column;margin-top: 5px;">
					<view style="display: flex;flex-direction: row;font-size: 16px;font-weight: 600;color: #515151;align-items: center;justify-content: center;">
						您还未登录
					</view>
					<view style="display: flex;flex-direction: row;font-size: 14px;color: #909399;align-items: center;justify-content: center;margin: 5px 0 10px 0;">
						请先登录再进行操作
					</view>
				</view>
			</view>
			<view style="display: flex;flex-direction: row;align-items: center;margin: 10px 0 10px 0;">
				<view @click="handCloseLogin" style="border-radius: 25px;border: 1px solid rgba(0,0,0,.2);background-color: #F8F8F8;font-size: 15px;color: #666;flex: 1;display: flex;flex-direction: row;justify-content: center;align-items: center;height: 45px;margin-right: 5px;">
					暂不登录
				</view>
				<view style="border-radius: 25px;border: 1px solid rgba(0,0,0,.2);background: linear-gradient(to right,#c2b292,#dacdbe);font-size: 15px;color: #666;flex: 1;display: flex;flex-direction: row;justify-content: center;align-items: center;height: 45px;margin-left: 5px;">
					<button type="primary" open-type="getPhoneNumber" @getphonenumber="handleToLogins" plain="true" style="border: none;color: #666;font-size: 15px;">立即登录</button>
				</view>
			</view>
			
		</view>
	</uni-popup>
  </view>
</template>

<script>
  import storage from '@/utils/storage'
  import store from "@/store"
  import uniNavBarMine from '../../components/uni-nav-barMine/components/uni-nav-bar/uni-nav-barMine.vue'
  import carousel from '@/components/vear-carousel/vear-carousel'
  import { getToken } from '@/utils/auth'
  
  export default {
	components:{
		uniNavBarMine,carousel
	},
	onShow() {
		console.log('________进入_我的_onShow__--',this.name)
		if(this.userinfo !== ''){
			console.log('_______用户信息不为空，初始化待收货数量_--')
			
			this.initOrderThreeTotal();
		}
	},
	created() {
		//console.log('________进入__created__--',this.name)
		
		// console.log(this.txCloudEnvID,'____prod-8gfkdv4319060502_____txCloudEnvID_____',this.vxService)
		// wx.cloud.callContainer({
		//   "config": {
		//     "env": this.txCloudEnvID
		//   },
		//   "path": "/system/kind/list",
		//   "header": {
		//     "X-WX-SERVICE": this.vxService,
		//     "content-type": "application/json"
		//   },
		//   "method": "GET",
		//   "data": ""
		// }).then((res) =>{
		// 	console.log(res)//status: 400
		// 	console.log(res.data.code)
		// 	console.log(res.data.data)
		// })
	},
    data() {
      return {
        //name: this.$store.state.user.name,
		//userinfo:this.$store.state.user.userinfo,
		//avatar:'',
        version: getApp().globalData.config.appInfo.version,
		txCloudEnvID:getApp().globalData.config.appInfo.txCloudEnvID,
		vxService:getApp().globalData.config.appInfo.vxService,
		serviceMobile:'',//客服电话
		problemDescribeVal:'',//问题反馈内容
		show: false,
		styles: {
			height:"100%",
			backgroundColor:"#fff",
			borderRadius: "10px"
		},
		imgList: [{
				id: 1,
				url: 'https://mail-activity.nosdn.127.net/54d46d33-810a-4f3d-9e14-a8671608feeb'
			},{
				id: 2,
				url: 'https://env-00jxh1npxfng.normal.cloudstatic.cn/login-background (2).jpg?expire_at=1722196582&er_sign=1d900f1442c414bdc30cd1cd6c02f169'
			},{
				id: 3,
				url: 'https://env-00jxh1npxfng.normal.cloudstatic.cn/login-background.jpg?expire_at=1722196670&er_sign=6078c53711a73333db574960e8a4ffc8'
			},{
				id: 4,
				url: 'https://env-00jxh1npxfng.normal.cloudstatic.cn/a_看图王.jpg?expire_at=1722196790&er_sign=966e07cbdcbe78c798cf670ea458f87a'
		}],
		orderThreeVal:0,//待收货角标。
		orderType:-1,// -1查看所有订单>>订单状态：0:待付款,1:待发货,2:已发货,3:已完成
		
      }
    },
    computed: {		
      avatar() {
		return this.$store.state.user.avatar
      },
	  name() {
	    return this.$store.state.user.name
	  },
	  userinfo() {
	    return this.$store.state.user.userinfo
	  },
      windowHeight() {
        return uni.getSystemInfoSync().windowHeight - 0
      },
	  windowWidth() {
	    return uni.getSystemInfoSync().windowWidth - 0
	  }
    },
    methods: {
		openPopup() {
		  this.show = true;
		},
		cancelPopup() {
		  // 登录逻辑处理
		  this.show = false;
		},
	  selectedBanner(item, index) {
		console.log('————轮播——', item, index)
	  },
	  userXieYi(){
		this.$tab.navigateTo('/pagesA/userXieYi/userXieYi')
	  },
	  userYinsi(){
		this.$tab.navigateTo('/pagesA/userYinSi/userYinSi')
	  },
      handleToInfo() {
        this.$tab.navigateTo('/pages/mine/info/index')
      },
      handleToEditInfo() {
        this.$tab.navigateTo('/pages/mine/info/edit')
      },
	  handCloseLogin(){
		  this.$refs.loginPop.close();
	  },
      handleToSetting() {
        this.$tab.navigateTo('/pages/mine/setting/index')
      },
	  codeLogin(){
	  	this.$tab.navigateTo('/pages/mine/login/index')
	  },
      handleToLogin(data) {
        //this.$tab.reLaunch('/pages/login')
		let res = data.detail;
		if(res.errMsg === 'getPhoneNumber:ok'){
			console.log(res.code,'_________')
		    const result = wx.cloud.callContainer({
		      "config": {
		        "env": this.txCloudEnvID
		      },
		      "path": "/wx/getPhoneNumbers?code="+res.code,
		      "header": {
		        "X-WX-SERVICE": this.vxService,
		        "content-type": "application/json"
		      },
		      "method": "GET",
		      "data": ""
		    }).then((res) =>{
				console.log(res)
				//console.log(res.data.data)
				if(res.data.code == 200){
					this.$store.dispatch('Logins', res.data.data).then(() => {
						this.initOrderThreeTotal();
					}).catch(() => {
					})
				}
			}).catch((e) =>{
				console.log(e.message);
				if(e.message.indexOf('102002') !== -1){
					this.$modal.showToast('请求超时')
				}else if(e.message.indexOf('-606003') !== -1){
					this.$modal.showToast('账号欠费，登录失败，请联系管理员')
				}else{
					this.$modal.showToast('登录异常，请联系管理员')
				}
			})
		}
      },
	  showAllOrder(){//查看所有订单>>订单状态：0:待付款,1:待发货,2:已发货,3:已完成
		this.$tab.navigateTo('/pagesA/order/index?orderType=-1');
		
		// if(this.userinfo !== ''){
		// 	this.$tab.navigateTo('/pagesA/order/index?orderType=-1');
		// }else{
		// 	this.$refs.loginPop.open();
		// 	this.orderType = -1;
		// }
	  },
	  showAllOrderOne() {//待付款
	  
		this.$tab.navigateTo('/pagesA/order/index?orderType=0');
	  
		// if(this.userinfo !== ''){
		// 	this.$tab.navigateTo('/pagesA/order/index?orderType=0');
		// }else{
		// 	this.$refs.loginPop.open();
		// 	this.orderType = 0;
		// }
	  	
	  },
	  showAllOrderTwo(){//待发货
		this.$tab.navigateTo('/pagesA/order/index?orderType=1');
		  // if(this.userinfo !== ''){
		  // 	this.$tab.navigateTo('/pagesA/order/index?orderType=1');
		  // }else{
		  // 	this.$refs.loginPop.open();
		  // 	this.orderType = 1;
		  // }
	  },
	  showAllOrderThree(){//已发货
		this.$tab.navigateTo('/pagesA/order/index?orderType=2');
		// if(this.userinfo !== ''){
		// 	this.$tab.navigateTo('/pagesA/order/index?orderType=2');
		// }else{
		// 	this.$refs.loginPop.open();
		// 	this.orderType = 2;
		// }
	  },
	  showAllOrderFour(){//已完成
		this.$tab.navigateTo('/pagesA/order/index?orderType=3');
		// if(this.userinfo !== ''){
		// 	this.$tab.navigateTo('/pagesA/order/index?orderType=3');
		// }else{
		// 	this.$refs.loginPop.open();
		// 	this.orderType = 3;
		// }
	  },
	  getUserAvatar(data){
		  if(this.userinfo !== ''){
			  console.log(this.userinfo.clientId,'____客户主键id__')
			   wx.cloud.uploadFile({
			     cloudPath: 'mallAvatar/'+this.randomString(32)+'.jpg', // 对象存储路径，根路径直接填文件名，文件夹例子 test/文件名，不要 / 开头
			     filePath: data.detail.avatarUrl, // 微信本地文件，通过选择图片，聊天文件等接口获取
			     config: {
			       env: this.txCloudEnvID // 需要替换成自己的微信云托管环境ID
			     }
			   }).then(res => {
				 let formData ={
					 clientId:this.userinfo.clientId,
					 pic:res.fileID,
				 }
				 
				 wx.cloud.callContainer({
				   "config": {
				     "env": this.txCloudEnvID
				   },
				   "path": "/system/client",
				   "header": {
				     "X-WX-SERVICE": this.vxService,
				     "content-type": "application/json"
				   },
				   "method": "PUT",
				   "data": formData
				 }).then((res) =>{
					 //console.log(res)
					 this.$modal.showToast('上传成功！')
					 store.commit('SET_AVATAR', formData.pic)
				 }).catch((e) =>{
					  if(e.message.indexOf('102002') !== -1){
						this.$modal.showToast('请求超时')
					  }else{
						this.$modal.showToast(e.message)
					  }
				 })
			   }).catch(error => {
					this.$modal.showToast(err.message)
			   })
		  }else{
			  this.$modal.showToast('请先登录')
		  }
	  },
	  handleCoupon(){//优惠券
		this.$tab.navigateTo('/pages/mine/coupon/index')
	  },
      handleLogout() {
		if(this.userinfo){
			this.$modal.confirm('确定注销并退出系统吗？').then(() => {
			  this.$store.dispatch('LogOuts').then(() => {
			    this.$tab.reLaunch('/pages/mine/index')
			  })
			})
		}else{
			this.$modal.showToast('请先登录')
		}
      },
	  handleProblemDescribe(){//问题反馈
		  if(this.userinfo !== ''){
		  	this.$refs.problemDescribePop.open();
		  }else{
		  	this.$modal.showToast('请先登录')
		  }
	  },
	  closeProblemDescribePop(){
		  this.$refs.problemDescribePop.close();
	  },
	  handAddProblem(){//提交问题
		  if(this.problemDescribeVal.length == 0){
			  this.$modal.showToast('请输入内容')
			  return;
		  }
		  let formData ={
			  "mobile":this.userinfo.mobile,
			  "content":encodeURIComponent(this.problemDescribeVal),
			  "status":0,//状态：0:待解决，1:已解决
		  }
		  wx.cloud.callContainer({
			"config": {
			  "env": this.txCloudEnvID
			},
			"path": "/system/problem",
			"header": {
			  "X-WX-SERVICE": this.vxService,
			  "content-type": "application/json"
			},
			"method": "POST",
			"data": formData
		  }).then((res) =>{
				//console.log(res);
				uni.showToast({
					title: '反馈成功',
					icon:"success"
				});
				this.problemDescribeVal = '';
				this.$refs.problemDescribePop.close();
			}).catch((e) =>{
				console.log(e.message);
				if(e.message.indexOf('102002') !== -1){
					this.$modal.showToast('请求超时')
				}else{
					this.$modal.showToast(e.message)
				}
			})
		  
	  },
	  handleCallService(){//客户电话
		  wx.cloud.callContainer({
		    "config": {
		      "env": this.txCloudEnvID
		    },
		    "path": "/system/wxservice/list",
		    "header": {
		      "X-WX-SERVICE": this.vxService,
		      "content-type": "application/json"
		    },
		    "method": "GET",
		    "data": ""
		  }).then((res) =>{
			  let resultPhone = res.data.data;
			  //console.log(resultPhone,'_______')
			  if(resultPhone.length > 0){
				wx.makePhoneCall({
				    phoneNumber: resultPhone[0].serviceMobile,//获取所以列表第一个的客服电话
				})
			  }else{
				  this.$modal.showToast('不存在客服电话！')
			  }
		  }).catch((e) =>{
			  if(e.message.indexOf('102002') !== -1){
			  	this.$modal.showToast('请求超时')
			  }else{
			  	this.$modal.showToast(e.message)
			  }
		  })

	  },
      handleAddRess() {//收货地址
		//console.log(this.userinfo)
        // this.$tab.navigateTo('/pages/mine/address/index')
		this.$tab.navigateTo('/pagesA/address/index')
      },
      handleAbout() {
        this.$tab.navigateTo('/pages/mine/about/index')
      },
	  handleAvatarToLoginTip(){
		this.$modal.showToast('未登录')
	  },
	  handEditPhoto(){
		let _this = this;
		if(_this.userinfo === ''){
			this.$modal.showToast('请先登录')
			return;
		}
		uni.chooseImage({
			count: 1, //默认9
			//sourceType: ['album'], //从相册选择
			success: function (res) {
				console.log(res.tempFilePaths[0]);
				if(_this.userinfo !== ''){
				  console.log(_this.userinfo.clientId,'____客户主键id__',_this.userinfo)
				   wx.cloud.uploadFile({
					 cloudPath: 'mallAvatar/'+_this.randomString(32)+'.jpg', // 对象存储路径，根路径直接填文件名，文件夹例子 test/文件名，不要 / 开头
					 filePath: res.tempFilePaths[0], // 微信本地文件，通过选择图片，聊天文件等接口获取
					 config: {
					   env: _this.txCloudEnvID // 需要替换成自己的微信云托管环境ID
					 }
				   }).then(res => {
					 let formData ={
						 clientId:_this.userinfo.clientId,
						 pic:res.fileID,
					 }
					 
					 wx.cloud.callContainer({
					   "config": {
						 "env": _this.txCloudEnvID
					   },
					   "path": "/system/client",
					   "header": {
						 "X-WX-SERVICE": _this.vxService,
						 "content-type": "application/json"
					   },
					   "method": "PUT",
					   "data": formData
					 }).then((res) =>{
						 //console.log(res)
						 _this.$modal.showToast('上传成功！')
						 store.commit('SET_AVATAR', formData.pic)
					 }).catch((e) =>{
						  if(e.message.indexOf('102002') !== -1){
							_this.$modal.showToast('请求超时')
						  }else{
							_this.$modal.showToast(e.message)
						  }
					 })
				   }).catch(error => {
						_this.$modal.showToast(err.message)
				   })
				}else{
				  _this.$modal.showToast('主键id标识异常！')
				}
			}
		});
	  },
	  randomString(len) {
		  len = len || 32;　　
		  let $chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';　　
		  let maxPos = $chars.length;　　
		  let pwd = '';　　
		  for(let i = 0; i < len; i++) {
		  //0~32的整数
			pwd += $chars.charAt(Math.floor(Math.random() * (maxPos + 1)));　　
		  }
		  return pwd;
	  },
	  handleToLogins(data){//针对未登录查看订单
		  let _this = this;
		  
		  let res = data.detail;
		  if(res.errMsg === 'getPhoneNumber:ok'){
		  	console.log(res.code,'_________')
		      const result = wx.cloud.callContainer({
		        "config": {
		          "env": this.txCloudEnvID
		        },
		        "path": "/wx/getPhoneNumbers?code="+res.code,
		        "header": {
		          "X-WX-SERVICE": this.vxService,
		          "content-type": "application/json"
		        },
		        "method": "GET",
		        "data": ""
		      }).then((res) =>{
		  		console.log(res)
		  		//console.log(res.data.data)
		  		if(res.data.code == 200){
		  			this.$store.dispatch('Logins', res.data.data).then(() => {
						
						console.log(_this.orderType,'___订单类型_登录成功_')
						this.$refs.loginPop.close();
						this.$tab.navigateTo('/pagesA/order/index?orderType='+_this.orderType);
		  			}).catch(() => {
		  			})
		  		}
		  	}).catch((e) =>{
		  		console.log(e.message);
		  		if(e.message.indexOf('102002') !== -1){
		  			this.$modal.showToast('请求超时')
		  		}else if(e.message.indexOf('-606003') !== -1){
		  			this.$modal.showToast('账号欠费，登录失败，请联系管理员')
		  		}else{
		  			this.$modal.showToast('登录异常，请联系管理员')
		  		}
		  	})
		  }
	  },
	  initOrderThreeTotal(){//初始化待收货数量
		  let _this = this;
		  
		  // 订单类型：-1:查看全部,0:待付款,1:待发货,2:已发货,3:已完成
		  /* "/system/order/list?clientId=1&orderStatus=2&pageNum=1&pageSize=1" */
		  let path = "/system/order/list?clientId="+this.userinfo.clientId+"&orderStatus=2&pageNum=1&pageSize=1";
		  wx.cloud.callContainer({
		    "config": {
		      "env": this.txCloudEnvID
		    },
		    "path": path,
		    "header": {
		      "X-WX-SERVICE": this.vxService,
		      "content-type": "application/json"
		    },
		    "method": "GET",
		    "data": ""
		  }).then((res) =>{
		  	console.log(res);
		  	_this.orderThreeVal = res.data.total;
			
		  	
		  }).catch((e) =>{
		  	console.log(e.message);
		  	if(e.message.indexOf('102002') !== -1){
		  		this.$modal.showToast('请求超时')
		  	}else{
		  		this.$modal.showToast(e.message)
		  	}
		  })
		  
	  }
	  
    }
  }
</script>

<style lang="scss">
  page {
    background-color: #F6F6F6;
  }
  	.but-img{
		background-color: none !important;
		background: none !important;
		border: none !important;
		font-size: 33rpx;
  		&::after {
  		  border: none;
  		}
  	}
  	.grid-item-box {
  		//flex: 1;
  		// position: relative;
  		/* #ifndef APP-NVUE */
  		display: flex;
  		/* #endif */
  		flex-direction: column;
  		align-items: center;
  		justify-content: center;
  		padding: 0px 0;
		height: 100%;
  	}

  .mine-container {
    width: 100%;
    height: 100%;

    .header-section {
      padding: 15px 15px 45px 15px;
      background-color: #3c96f3;
      color: white;

      .login-tip {
        font-size: 18px;
        margin-left: 10px;
      }

      .cu-avatar {
        //border: 2px solid #eaeaea;
		
        .icon {
          font-size: 40px;
        }
      }

      .user-info {
        margin-left: 15px;

        .u_title {
          font-size: 18px;
          line-height: 30px;
        }
      }
    }
	
	.mine-actions {
	  padding-top: 10px;
	
	  .action-item {
	    .icon {
	      font-size: 28px;
	    }
	
	    .text {
	      display: block;
	      font-size: 13px;
	      margin: 8px 0px;
	    }
	  }
	}

    .content-section {
      //position: relative;
      // top: -50px;

    }
	.popup {
	  position: fixed;
	  bottom: 0;
	  width: 100%;
	}
	.mask {
	  position: absolute;
	  top: 0;
	  left: 0;
	  width: 100%;
	  height: 100%;
	  background-color: rgba(0, 0, 0, 0.5);
	}
	.login-form {
	  position: absolute;
	  bottom: 0;
	  width: 100%;
	  background-color: #fff;
	}
  }
</style>
